#ifndef _SHADOW_SOCKET_POOL_H_
#define _SHADOW_SOCKET_POOL_H_

#include <vector>
#include <string>

#include <log4cxx/logger.h>
#include <log4cxx/xml/domconfigurator.h>

#include "SSocket.h"
#include "ResourcePool.h"

#define SSOCKET_RES_FLAG_NOT_CONNECTED 1
#define SSOCKET_RES_FLAG_CONNECTED 2 

using std::vector;
using std::string;

class SocketPool {
		public:
				SocketPool();
				~SocketPool();

				int init(int pool_num, const char *ip, int port, int conn_timeout_in_sec);
				SSocket * acquire_socket();
				int release_socket(SSocket *); 
		protected:
				int reconnect_socket_resource(SSocket & s);
		private:
				ResourcePool _res_pool;
				vector<SSocket> _sockets;
				string _dst_ip;
				int _dst_port;
				int _conn_timeout_in_sec;
				log4cxx::LoggerPtr _logger;
};
#endif
